package com.example.hangzhou.welbeing.mytestdemoapp.factory;

import android.support.v4.app.Fragment;

import com.example.hangzhou.welbeing.mytestdemoapp.fragment.CircleFragment;
import com.example.hangzhou.welbeing.mytestdemoapp.fragment.MallFragment;
import com.example.hangzhou.welbeing.mytestdemoapp.fragment.MeFragment;
import com.example.hangzhou.welbeing.mytestdemoapp.fragment.MyHomePagerFragment;

import java.util.HashMap;

/**
 * 杭州惟君医疗科技有限公司14
 * Created by 20433 on 2018/2/27
 */

public class MainFragmentFactory {
    private static final int HOME_PAGER = 0; //Home page
    private static final int CIRCLE = 1;  //circle
    private static final int MALL = 2;
    private static final int ME = 3;
    private static HashMap<Integer, Fragment> mapAll = new HashMap();
    public static Fragment CreateCircleObject(int position) {
        Fragment fragment = mapAll.get(position);
        if (fragment == null)
        {
            switch (position){
                case HOME_PAGER:
                    fragment = new MyHomePagerFragment();
                    break;
                case CIRCLE:
                    fragment =  new CircleFragment();
                    break;
                case MALL:
                    fragment = new MallFragment();
                    break;
                case ME:
                    fragment = new MeFragment();
                    break;
            }
            mapAll.put(position,fragment);
            return fragment;
        }
        return fragment;
    }
}
